﻿using System.Collections.Generic;

namespace Basmus.Values
{
    public class ValuesProvider<TValue> : IValuesProvider<TValue>
    {
        private IDictionary<string, IEnumerable<TValue>> _dictionary;
            
        public ValuesProvider()
        {
            _dictionary = new Dictionary<string, IEnumerable<TValue>>();
        }

        public ValuesProvider(IDictionary<string,IEnumerable<TValue>> dictionary)
        {
            _dictionary = dictionary;
        }
        public void Set(string name, IEnumerable<TValue> values)
        {
            _dictionary[name] = values;
        }

        public IEnumerable<string> GetNames()
        {
            var names = _dictionary.Keys;
            return names;
        }

        public IEnumerable<TValue> GetValues(string name)
        {
            IEnumerable<TValue> values;
            if (_dictionary.TryGetValue(name, out values))
                return values;
            
            return null;
        }
    }
}